package com.probiz.estore.content.dao.impl;

import java.util.List;

import com.probiz.estore.Constants;
import com.probiz.estore.common.model.content.NewsletterGroup;
import com.probiz.estore.content.dao.NewsletterGroupDao;
import com.probiz.estore.core.dao.impl.HibernateGenericDaoImpl;
import com.probiz.estore.core.model.BaseObject;

/**
 * Dao implementation for NewsletterGroup.
*/
public class NewsletterGroupDaoImpl extends HibernateGenericDaoImpl<NewsletterGroup> implements NewsletterGroupDao {

	@Override
	protected void initFilterHqlMap() {
		filterHqlMap.put(BaseObject.FilterHqlName.DEFAULT, "select s from NewsletterGroup s order by s.updateTime desc");
	}
	
	/**
	 * 获取所有已激活的可在前台显示的消息组列表
	 * @return
	 */
	public List<NewsletterGroup> getAllNewsletterGroupList(Short status){
		String hql = "from NewsletterGroup nlg where nlg.isVisibleToFront=?";
		if(status!=null)
			hql += " and nlg.status=" + status;
		hql += " order by nlg.sortOrder";
		return this.findByHql(hql, Constants.FLAG_TRUE);
	}

}
